<?php
# $Id:
$alert = $template['alert'];
$trigger = $template['trigger'];
require_once(APP_LIB_DIR . 'Sajax.php');
require_once('utils.inc.php');
function lookup($what=''){
  $l = new LoginAction();
  return $l->lookup($what);
}

sajax_init();
sajax_export('lookup');
sajax_export('save');
sajax_handle_client_request();

$sajax_request_type = 'POST';
require('header_admin.php');
?>
<script language="javascript" type="text/javascript">
<?php sajax_show_javascript();?>

function setfocus()
{
    document.loginForm.username.select();
    document.loginForm.username.focus();
}

function check_alert()
{
    var message = '<?=$alert?>';
    var trigger = '<?=$trigger?>';
    if(message && trigger == 1){
        alert(message);
	return false;
    }else{
        return true;
    }
}

function privilege_cb (new_data){
    data = Json_eval(new_data);
    AddToOptionList(data, $('privilege'), 'id','usertype_name')
}

</script>
<body onLoad="setfocus(); check_alert();" class="bodyimage">
<div id="border-top" class="h_blue">
  <span class="title"><a href="index.php">STUDENT ATTENDANCE AND MESSAGING SYSTEM</a></span>
</div>
<div id="content-box">
  <div id="element-box" class="login">
    <div class="m wbg">
      <h1>Administration Login</h1>
      <div id="section-box">
        <div class="m">
	  <form id="loginForm" name="loginForm" method="POST" action="?module=<?=DEFAULT_MODULE?>&action=Login" style="clear: both;" >
          <!--USERNAME-->
          <fieldset class="loginform">
            <label id="mod-login-username-lbl" for="mod-login-username">User Name</label>
            <input name="username" id="mod-login-username" type="text" class="inputbox" size="15" />
            <label id="mod-login-password-lbl" for="mod-login-password">Password</label>
            <input name="pass" id="mod-login-password" type="password" class="inputbox" size="15" />
        <!--    <label id="mod-login-password-lbl" for="mod-login-password">School</label>
            <span><select id="privilege" name="privilege"></select></span>-->
            <div class="clr"></div>
            <div class="button_holder">
              <div class="button1">
                <div class="next">
                  <a href="#" onclick="document.getElementById('loginForm').submit();" name="flag">Log in</a>
                </div>
              </div>
            </div>
            <div class="clr"></div>
	     <input type="submit" name="flag" value="Login" class="hidebtn">
             <input type="hidden" id="flag" name="flag" value="Login">
          </fieldset>
          </form>
          <div class="clr"></div>
        </div>
      </div>
      <p>Welcome to <?php global $config; echo $config['title'];?>!</p>
      <p>Use a valid username and password to gain access to the administrator backend.</p>
      <p><a href="http://localhost/MCS-SMS/">Go to site home page.</a></p>
      <div id="lock"></div>
    </div>
  </div>
</div>
</br> 
<script type="text/javascript">
x_lookup('privilege',privilege_cb)
</script>
<?php require('footer.php'); ?>
</body>
</html>
